#include"vector.h"

void test1()
{
	int arr[3] = { 1, 2, 3 };
	MyVector::vector<int> v1;
	MyVector::vector<int> v2(3, 2);
	MyVector::vector<int> v3(arr, arr + 2);
	MyVector::vector<int> v4(v3);
	MyVector::vector<int> v5 = v4;
	for (auto ch : v1)
	{
		cout << ch;
	}
	for (auto ch : v2)
	{
		cout << ch;
	}
	cout << endl;
	for (auto ch : v3)
	{
		cout << ch;
	}
	cout << endl;
	for (auto ch : v4)
	{
		cout << ch;
	}
	cout << endl;
	for (auto ch : v5)
	{
		cout << ch;
	}
}

void test2()
{
	MyVector::vector<int> v1(10, 2);
	cout << v1.size() << ' ' << v1.capacity() << endl;
	for (auto ch : v1)
	{
		cout << ch;
	}
	cout << endl;

	v1.reserve(2);
	cout << v1.size() << ' ' << v1.capacity() << endl;
	for (auto ch : v1)
	{
		cout << ch;
	}
	cout << endl;

	v1.reserve(20);
	cout << v1.size() << ' ' << v1.capacity() << endl;
	for (auto ch : v1)
	{
		cout << ch;
	}
}

void test3()
{
	MyVector::vector<int> v1(10, 2);
	cout << v1.size() << ' ' << v1.capacity() << endl;
	for (auto ch : v1)
	{
		cout << ch;
	}
	cout << endl;

	v1.resize(5);
	cout << v1.size() << ' ' << v1.capacity() << endl;
	for (auto ch : v1)
	{
		cout << ch;
	}
	cout << endl;

	v1.resize(7, 3);
	cout << v1.size() << ' ' << v1.capacity() << endl;
	for (auto ch : v1)
	{
		cout << ch;
	}
	cout << endl;

	v1.resize(20, 4);
	cout << v1.size() << ' ' << v1.capacity() << endl;
	for (auto ch : v1)
	{
		cout << ch;
	}
	cout << endl;
}

void test4()
{
	MyVector::vector<int> v1(2, 2);
	cout << v1.size() << ' ' << v1.capacity() << endl;
	for (auto ch : v1)
	{
		cout << ch;
	}
	cout << endl;

	v1.push_back(3);
	v1.push_back(4);
	v1.push_back(5);

	cout << v1.size() << ' ' << v1.capacity() << endl;
	for (auto ch : v1)
	{
		cout << ch;
	}
	cout << endl;

	v1.pop_back();
	cout << v1.size() << ' ' << v1.capacity() << endl;
	for (auto ch : v1)
	{
		cout << ch;
	}
	cout << endl;
}

void test5()
{
	MyVector::vector<int> v1(1, 2);
	cout << v1.size() << ' ' << v1.capacity() << endl;
	for (auto ch : v1)
	{
		cout << ch;
	}
	cout << endl;

	v1.insert(v1.begin(), 1);
	cout << v1.size() << ' ' << v1.capacity() << endl;
	for (auto ch : v1)
	{
		cout << ch;
	}
	cout << endl;

	v1.insert(v1.end(), 3);
	v1.insert(v1.end(), 4);
	v1.insert(v1.end(), 5);
	cout << v1.size() << ' ' << v1.capacity() << endl;
	for (auto ch : v1)
	{
		cout << ch;
	}
	cout << endl;

	v1.erase(v1.begin());
	cout << v1.size() << ' ' << v1.capacity() << endl;
	for (auto ch : v1)
	{
		cout << ch;
	}
	cout << endl;

	v1.erase(v1.end() - 1);
	cout << v1.size() << ' ' << v1.capacity() << endl;
	for (auto ch : v1)
	{
		cout << ch;
	}
	cout << endl;

}

int main()
{
	//test1();
	//test2();
	//test3();
	//test4();
	test5();
}